package com.TanNgee.loadbalance.loadbalancer;

import com.TanNgee.loadbalance.AbstractLoadBalance;
import com.TanNgee.remoting.dto.RpcRequest;

import java.util.List;
import java.util.Random;

/**
 * @author 陈毅
 * @create 2022/3/21 16:14
 */
public class RandomLoadBalance extends AbstractLoadBalance {
    @Override
    protected String doSelect(List<String> serviceAddresses, RpcRequest rpcRequest) {
        Random random = new Random();
        return serviceAddresses.get(random.nextInt(serviceAddresses.size()));
    }
}
